<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="0">
<title>登录</title>
<link href="../static/css/login.css" th:href="@{/css/login.css}" type="text/css" rel="stylesheet">
</head>
<body>

	<div class="login">
		<div class="message">博客后台管理系统</div>
		<div id="darkbannerwrap"></div>

		<form id="login-form" method="post" onsubmit="return false;">
			<input id="username" value="" name="username" placeholder="用户名" type="text"
				autocomplete="off">
			<hr class="hr15">
			<input id="password" value="" name="password" placeholder="密码" type="password"
				autocomplete="off">
			<hr class="hr15">
			<button style="width: 100%;" type="submit"
				onclick="login(this)">登录</button>
			<hr class="hr20">
			<span id="info" style="color: red"></span>
		</form>


	</div>

</body>
<script src="../static/plugins/jquery3.3.1.min.js" th:src="@{/plugins/jquery3.3.1.min.js}"></script>
<script type="text/javascript">

	function login(obj) {

		var username = $.trim($('#username').val());
		var password = $.trim($('#password').val());
		if (username == "" || password == "") {
			$("#info").html('用户名或者密码不能为空');
		} else {
			$.ajax({
				type : 'POST',
				url : '/loginCheck',
				data : {"username":username,"password":password},
				success : function(e) {
					if(e.success){
						window.location.href="/"
					}else{
						alert("用户名或密码错误！");
					}
				},
				dataType:"json"
			});

		}
	}
</script>
</html>